package com.topcheer.common.datasource.holder;

import com.topcheer.common.datasource.vo.SimpleDataSourceInfo;

/**
 * @ClassName: SimpleDataSourceInfoHolder
 * @Author: Lix
 * @Version: 1.0
 * @Date: 2019/12/26 14:18
 * @Description: TODO
 **/
public class SimpleDataSourceInfoHolder {

    private static ThreadLocal<SimpleDataSourceInfo> threadLocal = new ThreadLocal<>();

    /**
     * 向当前线程中存放数据源信息
     * @param simpleDataSourceInfo 简单数据源信息
     */
    public static void set(SimpleDataSourceInfo simpleDataSourceInfo){
        threadLocal.set(simpleDataSourceInfo);
    }

    /**
     * 从当前线程中获取简单数据源信息
     * @return DataSourceInfo
     */
    public static SimpleDataSourceInfo get(){
        return threadLocal.get();
    }

    /**
     * 删除当前线程中的简单数据源信息
     */
    public static void remove(){
        threadLocal.remove();
    }
}
